package com.sc.nft.util;

import cn.hutool.crypto.SecureUtil;

import java.util.regex.Pattern;

public class CheckAccountUtil {


    /**
     * MD5加密
     * @param pwd
     * @return
     */
    public static String pwdToMd5(String pwd){
        String userPassWordSalt = PropertiesUtil.getProperty("USER_PASS_WORD_SALT");
        return  SecureUtil.md5(SecureUtil.md5(pwd + userPassWordSalt));
    }

    //true是手机号，false不是手机号
    public static boolean checkPhone(String phone){
        Pattern p = Pattern.compile("^[1](([3-9][\\d])|([4][5,6,7,8,9])|([6][5,6])|([7][3,4,5,6,7,8])|([9][8,9]))[\\d]{8}$");
//        Pattern p = Pattern.compile("^(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$");
        if(p.matcher(phone).matches()){
            return true;
        }
        return false;
    }

    public static boolean checkEmail(String email) {
        Pattern p = Pattern.compile("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");

        if(p.matcher(email).matches()){
            return true;
        }
        return false;
    }
}
